﻿using EPiServer;
using EPiServer.Core;
using EPiServer.SpecializedProperties;
using JoelAbrahamsson.FeedImport;
using PageTypeBuilder;

namespace JoelAbrahamsson.PageTypes
{
    [PageType]
    public class Start : BasePageData
    {
        public override string ControllerName
        {
            get { return "Home"; }
        }

        public override string Slug
        {
            get
            {
                return string.Empty;
            }
        }

        [PageTypeProperty(Type = typeof(PropertyString))]
        public virtual string Tagline { get; set; }

        [PageTypeProperty]
        public virtual string HeaderGreeting { get; set; }

        [PageTypeProperty(Type = typeof(PropertyString))]
        public virtual string CommentNotificationEmailSubjectTemplate { get; set; }

        [PageTypeProperty]
        public virtual string CommentNotificationEmailTemplate { get; set; }

        [PageTypeProperty(Type = typeof(PropertyLinkCollection))]
        public virtual LinkItemCollection OldUrlMappings { get; set; }

        [PageTypeProperty(Type = typeof(PropertyPageReference))]
        public virtual SyndicationFeedRoot TwitterFeedRoot
        {
            get
            {
                PageReference pageReference = this.GetPropertyValue<Start, PageReference>(page => page.TwitterFeedRoot);
                if (pageReference == null)
                    return null;

                return DataFactory.Instance.GetPage(pageReference) as SyndicationFeedRoot;
            }
        }

        [PageTypeProperty(Type = typeof(PropertyPageReference))]
        public virtual SyndicationFeedRoot DeliciousFeedRoot
        {
            get
            {
                PageReference pageReference = this.GetPropertyValue<Start, PageReference>(page => page.DeliciousFeedRoot);
                if (pageReference == null)
                    return null;

                return DataFactory.Instance.GetPage(pageReference) as SyndicationFeedRoot;
            }
        }

        [PageTypeProperty(Type = typeof(PropertyLinkCollection))]
        public virtual LinkItemCollection FavoriteBlogs { get; set; }
    }
}
